package com.johnlee.sentinel_quick_start.controller;

import com.alibaba.csp.sentinel.SphO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController_03 {
    // availability
    @GetMapping("helloBoolean")
    public String helloBoolean() {
        // 使用限流规则
            if (SphO.entry("Sentinel_Boolean")) {
                try {
                    // 被保护的资源
                    return "Hello Sentinel " + "Boolean: TRUE";
                } finally {
                    SphO.exit();
                }
            } else {
                // 被限流或降级的处理
                return "Busy" + "Boolean: FALSE";
            }
    }
}

